<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>props</title>
    <style>

    </style>
</head>
<body>
<!--准备好一个容器-->
<div id="root"></div>
<div id="root2"></div>
<div id="root3"></div>

<!--引入React核心库-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react.development.js"></script>
<!--引入React-Dom，用于支持React操作Dom-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react-dom.development.js"></script>
<!--引入babel，用于将jsx转为js-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/babel.min.js"></script>

<script type="text/babel">

    //创建组件
    class Person extends React.Component {
        render() {
            const {name, sex, age} = this.props;
            return (
                <ul>
                    <li>姓名：{name}</li>
                    <li>性别：{sex}</li>
                    <li>年龄：{age + 1}</li>
                </ul>
            )
        }
    }

    //渲染组件到页面
    ReactDOM.render(<Person name='Tom' age={19} sex='男'/>, document.getElementById('root'));

    const p1 = {name: 'Jerry', age: 18, sex: '男'}
    ReactDOM.render(<Person name={p1.name} age={p1.age} sex={p1.sex}/>, document.getElementById('root2'));

    const p2 = {name: 'Tim', age: 20, sex: '女'}
    ReactDOM.render(<Person {...p2} />, document.getElementById('root3'));
</script>

</body>


</html>
